﻿using System;
using System.Windows.Forms;
using CefSharp;
using CefSharp.WinForms;

namespace winfrom_nested_chromium_75 {

  public partial class Form1 : Form {
    public ChromiumWebBrowser browser;
    

    public Form1() {
      InitializeComponent();
      initBrowser();
    }

    private void Form1_Load(object sender, EventArgs e) {

    }

    public void initBrowser() {
      CefSettings settings = new CefSettings();
      //禁止GPU(图形处理器) 加速
      settings.CefCommandLineArgs.Add("disable-gpu", "1");

      // Enable WebRTC   支持媒体流    
      settings.CefCommandLineArgs.Add("enable-media-stream", "1");

      //不要使用代理服务器，总是直接连接。覆盖传递的任何其他代理服务器标志。
      //略微改进了Cef初始化时间，因为它不会尝试解析代理
      settings.CefCommandLineArgs.Add("no-proxy-server", "1");
      settings.Locale = "zh-CN";
      //浏览器引擎的语言
      settings.AcceptLanguageList = "zh-CN,zh;q=0.8";
      //日志文件
      //保存回话
      settings.PersistSessionCookies = true;
      //设置缓存路径
      settings.CachePath = "cache";
      Cef.Initialize(settings);
      //http://ibotcluster.online.uairobot.com/manager
      //https://studio.dev.tencent.com/ws/wvjbby
      var url = PropertiesConfig.getValue("manager.url");
      browser = new ChromiumWebBrowser(url);
      this.Controls.Add(browser);
      browser.Dock = DockStyle.Fill;
    }
  }
}
